# Example Makefile script
# Purpose: Demonstrate usage of pkg-config with json-c libraries
#
# ========================= *IMPORTANT* ================================
# For this method to work json-c must be installed in your
# system in a path accesible to pkg-config. To check if pkg-config
# sees json-c config files, execute:
# pkg-config --list-all | grep json-c
# If no package appears, json-c is not installed or something else is wrong.
# ======================================================================

# Set up basic variables:
CC = gcc
CFLAGS = -c -Wall
LDFLAGS =

# List of sources:
SOURCES= json_c_parse.c 
OBJECTS= $(SOURCES:.c=.o)

# Name of executable target:
EXECUTABLE = json_c_parser

# json-c specific flags:
# Here we invoke "pkg-config" passing it as argument the list of the
# json-c libraries needed by our program (see available libs
# with "pkg-config --list-all | grep json-c").
CFLAGS += `pkg-config --cflags json-c`
LDFLAGS += `pkg-config --libs json-c`

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
	$(CC) $(OBJECTS) -o $@ $(LDFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) $< -o $@

.PHONY: clean

clean:
	rm $(OBJECTS) $(EXECUTABLE) 
